home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #49 (Oct 89) / DMP Source / src / MPWGlue.a < prev    next >
Text File  |  1989-01-02  |  5KB  |  206 lines

  1. ;;
  2. ;; Glue for Printer Driver code resource headers using MPW C.
  3. ;; The header for each type of resource is placed in a separate
  4. ;; module using the Asm PROC directive.  The "-m" option to the
  5. ;; linker makes it the entry point to the linked code resource.
  6. ;;
  7. ;; Earle R. Horton.  All rights reserved.
  8. ;;  Tuesday, December 13, 1988
  9. ;;
  10. ;; Some of the Glue routines contain data.  This is read-only!
  11. ;;
  12.  
  13.     CASE ON
  14.  
  15.     SEG 'Main'
  16.  
  17.     INCLUDE 'SysEqu.a'
  18.  
  19. myDrvrFlags EQU ((1<<dCtlEnable) + (1<<dStatEnable) + (1<<dNeedGoodBye)) << 8   ; Flag byte.
  20. ;;
  21. ;; The header for the 'DRVR' resource.
  22. ;;
  23. DriverEntry PROC    EXPORT  ;; 'DRVR' starts here.
  24.     IMPORT  myPrOpen    ; open routine
  25.     IMPORT  myPrPrime   ; prime
  26.     IMPORT  myPrControl ; control
  27.     IMPORT  myPrStatus  ; status
  28.     IMPORT  myPrClose   ; close
  29.     CODE
  30.  
  31.     DC.W    myDrvrFlags     ; control and status enable only
  32.     DC.W        0       ; doesn't need time
  33.     DC.W        0       ; no events
  34.     DC.W        0       ; no menu
  35.  
  36.  
  37.     DC.W    myPrOpenCall-DriverEntry    ; Offsets to driver routines.
  38.     DC.W    myPrPrimeCall-DriverEntry
  39.     DC.W    myPrControlCall-DriverEntry
  40.     DC.W    myPrStatusCall-DriverEntry
  41.     DC.W    myPrCloseCall-DriverEntry
  42.     STRING  PASCAL
  43.     DC.B    '.Print'        ; Driver name as Pascal string
  44.     DC.W    0           ; Zero for word-align.
  45. dummyheader             ; Make it look like a procedure for
  46.     LINK    A6,#0       ; MacsBug
  47. myPrOpenCall
  48.     PEA myPrOpen        ;; SP -> desired driver routine.
  49.     BRA.S   CallDriver  ;; Jump to interface to call real routine.
  50. myPrPrimeCall
  51.     PEA myPrPrime       ;; Times 5.
  52.     BRA.S   CallDriver
  53. myPrControlCall
  54.     PEA myPrControl
  55.     BRA.S   CallDriver
  56. myPrStatusCall
  57.     PEA myPrStatus
  58.     BRA.S   CallDriver
  59. myPrCloseCall
  60.     PEA myPrClose
  61. CallDriver
  62.     MOVE.L  A1,-(SP)        ;; Push pointer to device control entry.
  63.     MOVE.L  A0,-(SP)        ;; Push pointer to parameter block.
  64.     MOVEA.L 8(SP),A0        ;; Get routine address.
  65.     JSR (A0)                ;; Call driver routine.
  66.                             ;; Result is in D0.
  67.     MOVE.L  (SP)+,A0        ;; Restore registers.
  68.     MOVE.L  (SP)+,A1        ;; Note: C programs leave the stack alone.
  69.     ADDQ.W   #$4,A7         ;; Fix up stack pointer.
  70.     BTST    #$01,$0006(A0)  ;; Immediate call?
  71.     BNE.S   StdReturn       ;; Yes, regular return.
  72.     MOVE.L  JIODone,-(sp)   ;; No, return via IODone
  73. StdReturn
  74.     RTS
  75. label               ;; This is for MacsBug.
  76.     UNLK    A6
  77.     RTS
  78.     STRING  ASIS
  79.     DC.B    'DMP-110 '
  80.     ENDP
  81. ;;
  82. ;; The header for the Chooser Device Package.
  83. ;;
  84.     CASE OFF
  85.  
  86. PackEntry   PROC EXPORT
  87.     IMPORT  device
  88.     BRA.S   devicejump
  89. deviceID
  90.     DC.W    0
  91. Packname
  92.     DC.L    $5041434B   ; 'PACK'
  93. IDnumber
  94.     DC.W    $F000       ; -4096
  95. Version
  96.     DC.W    1
  97. Flags
  98.     DC.L    $0C00E000
  99. devicejump
  100.     JMP device
  101.  
  102.     ENDP
  103.  
  104. ;;
  105. ;; The header for the Job and Style Dialogs code.
  106. ;;
  107.     CASE OFF
  108. DialogsEntry    PROC    EXPORT
  109.         import  MyPrintDefault
  110.         import  MyPrStlDialog
  111.         import  MyPrJobDialog
  112.         import  MyPrStlInit
  113.         import  MyPrJobInit
  114.         import  MyPrDlgMain
  115.         import  MyPrValidate
  116.         import  MyPrJobMerge
  117.         bra.w   MyPrintDefault
  118.         bra.w   MyPrStlDialog
  119.         bra.w   MyPrJobDialog
  120.         bra.w   MyPrStlInit
  121.         bra.w   MyPrJobInit
  122.         bra.w   MyPrDlgMain
  123.         bra.w   MyPrValidate
  124.         bra.w   MyPrJobMerge
  125.         ENDP
  126. ;;
  127. ;; Routines to call Pascal procedures which are known by address
  128. ;; and not by name. (ProcPtr glue).
  129. ;;
  130.     CASE OFF
  131. CallDlgInit PROC EXPORT
  132.         Export  CallItemProc
  133. CallItemProc
  134.         MOVE.L  (SP)+,A0    ; Pop return address.
  135.         MOVE.l  (SP)+,A1    ; Pop actual function address.
  136.         MOVE.L  A0,-(SP)    ; Push return address.
  137.         JMP (A1)        ; Call the Pascal Function
  138.         ENDP
  139. ;;
  140. ;; The header for the printing code.
  141. ;;
  142.     CASE OFF    ; If main code is in Pascal.
  143.  
  144. PrintEntry  PROC    EXPORT
  145.     IMPORT  myPrOpenDoc
  146.     IMPORT  myPrCloseDoc
  147.     IMPORT  myPrOpenPage
  148.     IMPORT  myPrClosePage
  149.     bra.w   myPrOpenDoc
  150.     bra.w   myPrCloseDoc
  151.     bra.w   myPrOpenPage
  152.     bra.w   myPrClosePage
  153.     ENDP
  154.     CASE ON
  155. serialdata PROC EXPORT
  156. ;
  157. ;   This module consists of read-only data.
  158. ;
  159. baud300     EQU 380
  160. baud600     EQU 189
  161. baud1200    EQU 94
  162. baud1800    EQU 62
  163. baud2400    EQU 46
  164. baud3600    EQU 30
  165. baud4800    EQU 22
  166. baud7200    EQU 14
  167. baud9600    EQU 10
  168. baud19200   EQU 4
  169. baud57600   EQU 0
  170.  
  171.  
  172.     EXPORT AOutName,BOutName,BaudRates,prhireslf
  173.  
  174. ;
  175. ; Handy storage place for constant strings and data which can be copied
  176. ; by the Driver routines.
  177. ;
  178.     STRING  PASCAL
  179. AOutName
  180.     DC.B    '.AOut'
  181. BOutName
  182.     DC.B    '.BOut'
  183.     STRING ASIS
  184. prhireslf
  185.     dc.b    3,26,27,'G'
  186.  
  187.  
  188.     ALIGN   2
  189.  
  190. BaudRates
  191.     DC.W baud300
  192.     DC.W baud600
  193.     DC.W baud1200
  194.     DC.W baud1800
  195.     DC.W baud2400
  196.     DC.W baud3600
  197.     DC.W baud4800
  198.     DC.W baud7200
  199.     DC.W baud9600
  200.     DC.W baud19200
  201.     DC.W baud57600
  202.     ENDP
  203.  
  204.     END
  205.  
  206.